package top.tangyh.lamp.care.mapper;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import top.tangyh.basic.base.mapper.SuperMapper;
import top.tangyh.lamp.care.entity.BGenItemDetail;
import org.springframework.stereotype.Repository;
import top.tangyh.lamp.care.vo.query.GenItemDetailQueryParam;
import top.tangyh.lamp.care.vo.result.GenItemDetailMapDto;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * 通用项目配置明细表
 * </p>
 *
 * @author zqb
 * @date 2024-07-17 17:16:35
 * @create [2024-07-17 17:16:35] [zqb] [代码生成器生成]
 */
@Repository
public interface BGenItemDetailMapper extends SuperMapper<BGenItemDetail> {

    default void deleteByParentId(Long id){
        LambdaQueryWrapper<BGenItemDetail> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(BGenItemDetail::getGenId,id);
        delete(queryWrapper);
    }

    default List<BGenItemDetail> getByParentIds(List<Long> ids){
        LambdaQueryWrapper<BGenItemDetail> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(CollectionUtil.isNotEmpty(ids),BGenItemDetail::getGenId,ids);
        return selectList(queryWrapper);
    }

    /**
     * 查询通用管理明细，应用前端通用配轩管理
     *
     * @param param 查询参数 包含主表查询条件
     * @return
     */
    List<BGenItemDetail> queryDetail(GenItemDetailQueryParam param);


    /**
     * 查询所有含有明细的配置，应用于前端一次获得所有含有明细的配置
     *
     * @param param 查询参数
     * @return 主从层次结构返回数据
     */
    List<GenItemDetailMapDto> queryAll(GenItemDetailQueryParam param);

}


